package com.zzyweb.demomp.utils;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.sql.Date;
import java.time.LocalDateTime;

/**
 * @author zhiyi
 * @date 9/9/25
 **/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        System.out.println("开始自动填充 insert");
        this.strictInsertFill(metaObject, "createdDatetime", LocalDateTime.class,LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        System.out.println("开始自动填充 update");
        //this.strictInsertFill(metaObject, "createdDatetime", LocalDateTime.class,LocalDateTime.now());
        this.strictUpdateFill(metaObject,"updatedDatetime",LocalDateTime.class,LocalDateTime.now());
    }
}
